package im.domain;

import jade.content.onto.BasicOntology;
import jade.content.onto.Ontology;
import jade.content.onto.OntologyException;
import jade.content.schema.*;
/**
 * 
 * @deprecated Usare serializzazione XML
 *
 */
public class SLAOntology extends Ontology {

	public static final String ONTOLOGY_NAME = "SLAOntology";
	public static SLAOntology theInstance;
	
	//Concepts
	public static final String SLA = "SLA";
	public static final String MONITOR_DATA = "MONITOR_DATA";
	public static final String CONTEXT = "CONTEXT";
	
	//Slots SLA
	private static final String SERVIZIO = "servizio";
	public static final String SUBSCRIBER_A 	= "subscriberA";
	public static final String SUBSCRIBER_B 	= "subscriberB";
	public static final String TEMPO_RISP_MAX 	= "tempoRispMax";
	public static final String TASSO_ARRIVI_MAX = "tassoArriviMax";
	public static final String SUCCESS_RATE_MIN	= "successRateMin";
	//Slots MonitorData
	public static final String CONVERSATION_ID 	= "conversationId";
	public static final String TEMPO_RISP_LAST	= "tempoRispLast";
	public static final String TEMPI_INTERARRIVO= "tempiInterarrivo";
	public static final String REQ_RICEVUTE		= "reqRicevute";
	public static final String REQ_SODDISFATTE	= "reqSoddisfatte";
	//Slots Context
	public static final String NODE_ID			= "nodeId";
	public static final String CARICO_CPU		= "caricoCpu";
	public static final String RAM_DISP			= "ramDisp";
	public static final String MEM_STAB_DISP	= "memStabDisp";
	public static final String BANDA_DISP		= "bandaDisp";
	public static final String AUTONOMIA_RESIDUA= "autonomiaResidua";
	
	
	
	
	public SLAOntology(String name, Ontology base) {
		super(name, base);
		try {
            PrimitiveSchema stringSchema  = (PrimitiveSchema)getSchema(BasicOntology.STRING);
            PrimitiveSchema integerSchema = (PrimitiveSchema)getSchema(BasicOntology.INTEGER);
            PrimitiveSchema floatSchema = (PrimitiveSchema)getSchema(BasicOntology.FLOAT);
            //PrimitiveSchema setSchema = (PrimitiveSchema)getSchema(BasicOntology.SET);

            ConceptSchema slaSchema = new ConceptSchema(SLA);
            slaSchema.add(SERVIZIO, stringSchema,  ObjectSchema.MANDATORY);
            slaSchema.add(SUBSCRIBER_A, stringSchema,  ObjectSchema.MANDATORY);
            slaSchema.add(SUBSCRIBER_B, stringSchema, ObjectSchema.OPTIONAL);
            slaSchema.add(TEMPO_RISP_MAX, integerSchema, ObjectSchema.OPTIONAL);
            slaSchema.add(TASSO_ARRIVI_MAX,   floatSchema, ObjectSchema.OPTIONAL);
            slaSchema.add(SUCCESS_RATE_MIN,   floatSchema, ObjectSchema.OPTIONAL);
            

            ConceptSchema monitorDataSchema = new ConceptSchema(MONITOR_DATA);
            monitorDataSchema.add(CONVERSATION_ID,    stringSchema, ObjectSchema.MANDATORY);
            monitorDataSchema.add(TEMPO_RISP_LAST, integerSchema, ObjectSchema.OPTIONAL);
            //monitorDataSchema.add(TEMPI_INTERARRIVO, setSchema, ObjectSchema.OPTIONAL);
            monitorDataSchema.add(REQ_RICEVUTE, integerSchema, ObjectSchema.OPTIONAL);
            monitorDataSchema.add(REQ_SODDISFATTE, integerSchema, ObjectSchema.OPTIONAL);
            

            ConceptSchema contextSchema = new ConceptSchema(CONTEXT);
            contextSchema.add(NODE_ID, integerSchema, ObjectSchema.MANDATORY);
            contextSchema.add(CARICO_CPU, floatSchema, ObjectSchema.MANDATORY);
            contextSchema.add(RAM_DISP, integerSchema, ObjectSchema.MANDATORY);
            contextSchema.add(MEM_STAB_DISP, integerSchema, ObjectSchema.MANDATORY);
            contextSchema.add(BANDA_DISP, integerSchema, ObjectSchema.MANDATORY);
            contextSchema.add(AUTONOMIA_RESIDUA, integerSchema, ObjectSchema.MANDATORY);
            
            add(slaSchema,SLA.class);
            add(monitorDataSchema,MonitorData.class);
            add(contextSchema,Context.class);
            
        } catch(OntologyException oe) { 
        	oe.printStackTrace(); 
        }
    }
	
	public static SLAOntology getInstance(){
		if(theInstance==null){
			theInstance = new SLAOntology(
					ONTOLOGY_NAME,BasicOntology.getInstance());
		}
		return theInstance;
	}
}

	

